#!/usr/bin/env python
# -*- coding: iso-8859-15 -*-

#    Copyright (c) 2007, Corey Goldberg (corey@goldb.org)
#
#    This file is part of PerfLog.
#
#    PerfLog is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.


class Report(object):
    def __init__(self, output_name):
        self.handle = open(output_name, 'w')
        self.__write_initial_html()
    
    
    def writeln(self, txt):
        self.handle.write('%s\n' % txt)
    
    
    def __write_initial_html(self):
        self.handle.write("""\
    <!DOCTYPE html 
         PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>Analysis Report</title>
        
        <style type="text/css">
            body {
                font-size: 12px;
                background-color: #FFFFFF;
                color: #000000;
                font-family: Arial, Verdana, Helvetica, sans-serif;
                padding: 10px;
                }
            h1 {
                font-size: 16px;
                background: #F0F0F0;
                padding-left: 5px;
                }
            h2 {
                font-size: 14px;
                background: #F0F0F0;
                padding-left: 5px;
                }
            h3 {
                font-size: 13px;
                background: #F0F0F0;
                padding-left: 5px;
                }
        </style>
    </head>
    <body>
    """)
    
    
    def close(self):
        self.handle.write("""\
</body>
</html>
        """)
        self.handle.close()